package com.jz.community.moduleothers.scan.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.bean.baseCardInfo.BaseCardInfo;
import com.jz.community.basecomm.utils.BaseImageLoaderUtils;
import com.jz.community.basecomm.utils.Preconditions;
import com.jz.community.moduleothers.R;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class HomeQrCardAdapter extends BaseQuickAdapter<BaseCardInfo, BaseViewHolder> {

    public HomeQrCardAdapter(@Nullable List<BaseCardInfo> data) {
        super(R.layout.module_others_item_home_qrcard, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BaseCardInfo item) {
        String bgColor = !Preconditions.isNullOrEmpty(item.getColor()) ? item.getColor() : "#f2383b";

        CardView cardView = (CardView) helper.itemView;

        cardView.setCardBackgroundColor(Color.parseColor(bgColor));

        CircleImageView icon = helper.getView(R.id.iv_qrcard_item_icon);
        TextView name = helper.getView(R.id.tv_qrcard_item_name);
        TextView time = helper.getView(R.id.tv_qrcard_item_time);
        TextView balance = helper.getView(R.id.tv_qrcard_item_balance);
        balance.setText(item.getAmount() + "");
        name.setText(item.getBrand());
        BaseImageLoaderUtils.getInstance().loadDefaltImage(mContext, icon, item.getBrandIcon());
    }
}
